

import 'package:bruno/bruno.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:photo_view/photo_view.dart';

import '../../AppConfig/Config.dart';


class FeedbackProgressDetails extends StatefulWidget {
  const FeedbackProgressDetails({super.key, required this.dataMap});
  final Map dataMap;
  @override
  State<FeedbackProgressDetails> createState() => _FeedbackProgressDetailsState();
}

class _FeedbackProgressDetailsState extends State<FeedbackProgressDetails> {
  @override
  Widget build(BuildContext context) {
    final screenSize = MediaQuery.of(context).size;
    return Scaffold(
        backgroundColor: MyColors.backgreyColor,
        appBar: AppBar(
          backgroundColor: Colors.white,
          centerTitle: true,
          leading: IconButton(icon: Icon(Icons.arrow_back_ios,color: Colors.black,),onPressed: (){Navigator.pop(context);},),
          title: Text("意见反馈详情",style: TextStyle(color: Colors.black,fontWeight: FontWeight.w300,fontSize: 16.sp),),
        ),
        body:ListView(
          children: [
            Container(
              margin: EdgeInsets.only(left: 10.w,right: 10.w,top: 10.w),
              padding: EdgeInsets.only(left: 10.w,right: 10.w,top: 10.h,bottom: 10.h),
              decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.all(Radius.circular(10))),

              child: Column(
                children: [
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      BrnTagCustom(
                        tagText:widget.dataMap["status"]==1? '已处理':"等待处理",
                        backgroundColor: MyColors.themeColor,
                        textPadding:EdgeInsets.only(left: 4.w,right: 4.w,top: 2.h,bottom: 2.h),
                        fontSize: 12.sp,
                        tagBorderRadius:BorderRadius.all(Radius.circular(5)),
                      ),
                      Text(widget.dataMap['createTime'],style: TextStyle(color: MyColors.authTipColor,fontSize: 13.sp),),

                    ],
                  ),
                  SizedBox(height: 4.h,),
                  Container(
                      constraints: BoxConstraints(
                        maxWidth:screenSize.width-40.w, // 限制文本最大宽度
                      ),
                      child:
                      Text(widget.dataMap['firstStageDesc']!=null?widget.dataMap['firstStageDesc']:"",style: TextStyle(color: Colors.black,fontSize: 14.sp ),)
                  ),
                  Row(
                    children: [
                      Text(widget.dataMap['feedContent'],style: TextStyle(color: Colors.black,fontSize: 13.sp ),)
                    ],
                  ),
                  if(widget.dataMap['imagePath'].length>0)
                    Container(
                      margin: EdgeInsets.only(top: 8.h),
                      child:     Row(
                        children: [
                          GestureDetector(
                            child:  Image.network(MyServiceUrl.imgHeader+widget.dataMap['imagePath'][0] ,height: 60.h,width: 60.w,fit: BoxFit.cover, ),
                            onTap: (){
                              Navigator.push(
                                context,
                                MaterialPageRoute(
                                  builder: (context) => ImageViewer(MyServiceUrl.imgHeader+widget.dataMap['imagePath'][0]),
                                ),
                              );
                            },
                          ),                          SizedBox(width: 8.w,),
                          if(widget.dataMap['imagePath'].length>1)
                            GestureDetector(
                              child:  Image.network(MyServiceUrl.imgHeader+widget.dataMap['imagePath'][1] ,height: 60.h,width: 60.w,fit: BoxFit.cover, ),
                              onTap: (){
                                Navigator.push(
                                  context,
                                  MaterialPageRoute(
                                    builder: (context) => ImageViewer(MyServiceUrl.imgHeader+widget.dataMap['imagePath'][1]),
                                  ),
                                );
                              },
                            ),

                          SizedBox(width: 8.w,),
                          if(widget.dataMap['imagePath'].length>2)
                            GestureDetector(
                              child:  Image.network(MyServiceUrl.imgHeader+widget.dataMap['imagePath'][2] ,height: 60.h,width: 60.w,fit: BoxFit.cover, ),
                              onTap: (){
                                Navigator.push(
                                  context,
                                  MaterialPageRoute(
                                    builder: (context) => ImageViewer(MyServiceUrl.imgHeader+widget.dataMap['imagePath'][2]),
                                  ),
                                );
                              },
                            ),                        ],
                      ),
                    ),
              if(widget.dataMap['imagePath']!=null)
                Container(
                  margin: EdgeInsets.only(top: 8.h),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Text("处理内容",style: TextStyle(color:Colors.black,fontSize: 14.sp,fontWeight: FontWeight.w600 ),),
                      SizedBox(height: 4.h,),
                      Container(
                          constraints: BoxConstraints(
                            maxWidth:screenSize.width-40.w, // 限制文本最大宽度
                          ),
                          child:
                          Text(widget.dataMap['backContent'],style: TextStyle(color: Colors.black,fontSize: 14.sp ),)
                      ),
                    ],
                  ),
                ),


                ],
              ),
            ),
            // SizedBox(height: 8.h,),
            // Center(
            //   child: Text("暂无进度跟踪",style: TextStyle(color: MyColors.hintColor,fontSize:MyFontSizes.smallText.sp ),),
            // )
          ],
        )


    );
  }
}
class ImageViewer extends StatelessWidget {
  final String imagePath;

  ImageViewer(this.imagePath);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: GestureDetector(
        onTap: () {
          // 当点击大图时，返回上一个页面
          Navigator.pop(context);
        },
        child: PhotoView(
          imageProvider: NetworkImage(imagePath),
          minScale: PhotoViewComputedScale.contained * 0.8,
          maxScale: PhotoViewComputedScale.covered * 2,
        ),
      ),
    );
  }
}